package com.umeox.ota.gloable;

import android.content.Context;

import androidx.multidex.MultiDexApplication;

import com.umeox.ota.lifecycle.AppLifecycles;
import com.umeox.ota.data.repository.base.IRepository;

/**
 * @author fighter_lee
 * @date 2018/7/25
 */
public abstract class BaseApp extends MultiDexApplication implements IRepository{

    protected AppLifecycles mAppDelegate;

    /**
     * 这里会在 {@link BaseApp#onCreate} 之前被调用,可以做一些较早的初始化
     * 常用于 MultiDex 以及插件化框架的初始化
     *
     * @param base Context
     */
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        mAppDelegate = new AppDelegate(this);
        mAppDelegate.attachBaseContext(base);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mAppDelegate.onCreate(this);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        mAppDelegate.onTerminate(this);
    }
}
